home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt3sp4.arc / WRITCTRL.PAS < prev    next >
Pascal/Delphi Source File  |  1985-07-25  |  3KB  |  54 lines

  1. (*----------------------------------------------------------------------*)
  2. (*             Write_Ctrls --- Convert ctrl key defs in string          *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Write_Ctrls( S : AnyStr ) : AnyStr;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Function:   Write_Ctrls                                          *)
  10. (*                                                                      *)
  11. (*     Purpose:    Convert ctrl key defs to ascii sequences             *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Fixed_S := Write_Ctrls( S: AnyStr ) : AnyStr;                 *)
  16. (*                                                                      *)
  17. (*           S       --- the string with potential ctrl seqs to convert *)
  18. (*           Fixed_S --- fixed up string                                *)
  19. (*                                                                      *)
  20. (*     Remarks:                                                         *)
  21. (*                                                                      *)
  22. (*        This routine replaces control sequences like ^G (ascii 07)    *)
  23. (*        with a two-character sequence like '^G' -- ascii 94 +         *)
  24. (*        ascii 71. The actual '^' character                            *)
  25. (*        is the global parameter FK_Ctrl_Mark and can be set with      *)
  26. (*        a configuration file.                                         *)
  27. (*                                                                      *)
  28. (*----------------------------------------------------------------------*)
  29.  
  30. VAR
  31.    T: AnyStr;
  32.    I: INTEGER;
  33.  
  34. BEGIN (* Write_Ctrls *)
  35.                                    (* Scan for ctrl characters *)
  36.    T := '';
  37.  
  38.    FOR I := 1 TO LENGTH( S ) DO
  39.       BEGIN                        (* Ctrl char --- convert to marker  *)
  40.                                    (* plus ascii character             *)
  41.  
  42.          IF ( S[I] IN [^@..^_] ) THEN
  43.             T := T + FK_Ctrl_Mark + CHR( ORD( S[I] ) + 64 )
  44.  
  45.                                    (* Regular character -- just copy *)
  46.          ELSE
  47.             T := T + S[I];
  48.  
  49.       END;
  50.  
  51.    Write_Ctrls := T;
  52.  
  53. END   (* Write_Ctrls *);
  54.